// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

const db = cloud.database()
const _ = db.command
// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()

  let { myclass, keyword } = event
  return await db.collection("studentList").where(
  _.and([
    {
      grades:myclass
    }
    ,
    _.or(
      [
      {
        name: db.RegExp({
          regexp: '.*' + keyword,
          options: 'i',
        })
      },
      {
        studentId: db.RegExp({
          regexp: '.*' + keyword,
          options: 'i',
        })
      }
      ])
  ])  
    
 ).get()

  // return event
}